<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', '\App\Http\Controllers\LoginController@index');
Route::group(['middleware' => 'check.login'], function() {
	Route::get('/user/{user}','\App\Http\Controllers\UserController@show');
	//个人中心路由
	Route::post('/user/{user}/fan','\App\Http\Controllers\UserController@fan');
	Route::post('/user/{user}/unfan','\App\Http\Controllers\UserController@unfan');

	//个人页面设置
	Route::get('/user/me/setting','\App\Http\Controllers\UserController@setting');
	//个人页面设置储存
	Route::post('/user/me/settingStore','\App\Http\Controllers\UserController@settingStore');

	//文章列表页
	Route::get('/posts','\App\Http\Controllers\PostsController@index');
	//卡券列表页
	Route::get('/card','\App\Http\Controllers\CardController@index');
	//创建文章
	Route::get('/posts/create','\App\Http\Controllers\PostsController@create');
	Route::post('/posts','\App\Http\Controllers\PostsController@store');
	//创建卡
	Route::get('/card/create','\App\Http\Controllers\CardController@create');

	//文章详情页
	Route::get('/posts/{post}','\App\Http\Controllers\PostsController@show');
	//编辑文章
	Route::get('/posts/{post}/edit','\App\Http\Controllers\PostsController@edit');
	Route::put('/posts/{post}','\App\Http\Controllers\PostsController@update');
	//删除文章
	Route::get('/posts/{post}/delete','\App\Http\Controllers\PostsController@delete');
	//图片上传
	Route::post('/posts/image/upload','\App\Http\Controllers\PostsController@imageUpload');

	//创建评论
	Route::post('/posts/{post}/comment','\App\Http\Controllers\PostsController@comment');

	//点赞
	Route::get('/posts/{post}/zan','\App\Http\Controllers\PostsController@zan');
	//取消在赞
	Route::get('/posts/{post}/unzan','\App\Http\Controllers\PostsController@unzan');

	Route::post('/card/','\App\Http\Controllers\CardController@store');

	//专题详情页
	Route::get('/topic/{topic}','\App\Http\Controllers\TopicController@show');
	Route::get('/topic/{topic}/submit','\App\Http\Controllers\TopicController@submit');
});

//注册页面
Route::get('/register','\App\Http\Controllers\RegisterController@index');
//注册行为
Route::post('/register','\App\Http\Controllers\RegisterController@register');
//登录页面
Route::get('/login','\App\Http\Controllers\LoginController@index');
//登录行为
Route::post('/login','\App\Http\Controllers\LoginController@login');
//退出行为
Route::get('/logout','\App\Http\Controllers\LoginController@logout');

Route::group(['prefix' => 'admin'], function() {
	include_once('admin.php');
});




/*
路由访问检测是从上到下，当检测到｛｝时后面的会替换成含有｛｝

由于在create 之前有｛｝ 所以 laravel 会把create 换成｛create｝
 */
/*
Route::group(['prefix'=>'posts'],function(){
	Route::get('/','\App\Http\Controllers\PostsController@index');
	Route::get('/{id}','\App\Http\Controllers\PostsController@index');
	Route::get('/create','\App\Http\Controllers\PostsController@create');
});

*/




/* Route::get('/','controller@behavior');
Route::get("/","\App\Http\Controllers\PostsController@index");
Route::post("/","\App\Http\Controllers\PostsController@index");
Route::any("/","\App\Http\Controllers\PostsController@index");
Route::match(['post','get'],'/',"\App\Http\Controllers\PostsController@index");
Route::put("/posts","\App\Http\Controllers\PostsController@index");

<form action="/posts" method="post" accept-charset="utf-8">
	<input type="hidden" name="_method" value-"PUT"/>
	{{method_field("PUT")}}
</form>
 */
